public class 第五题 {
    public static int[] x = {25,18,-2,0,16,-5,33,21,0,19,-16,25,-3,0};

    static void sort(int[] x)
    {
        int p = 0;
        int left = 0;
        int right = x.length-1;

        while(p<=right){
            if(x[p]<0){
                int t = x[left];
                x[left] = x[p];
                x[p] = t;
                left++;
                p++;
            }
            else if(x[p]>0){
                int t = x[right];
                x[right] = x[p];
                x[p] = t;
                right--;
            }
            else{
                int t = x[left];x[left] = x[p];x[p] = t;  //代码填空位置
                p++;
            }
        }
    }


    public static void main(String[] args) {

        sort(x);

        for (int i = 0; i < x.length; i++) {
            System.out.print(x[i]+" ");
        }

    }

}

/*
* 如果给定数组：
25,18,-2,0,16,-5,33,21,0,19,-16,25,-3,0
则排序后为：
-3,-2,-16,-5,0,0,0,21,19,33,25,16,18,25*/
